-
Notifications
You must be signed in to change notification settings - Fork 8
Fixing a few issues #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
- Updated to .NET 7 images as project changed to use .NET 7 (from .NET 6) - Fixed COPY where it was copying WebDavService.Application CSPROJ that doesn't exist (or was renamed previously)
…tead to get rid of some unnecessary overhead (nitpicky I know) - Made the isDirectory check more reliable, found that in a WebDAV environment (Windows PC mapped drive to server), it picked up requests as not being a directory, causing some issues as the actual request (path) didn't end with "/" from GetPath() on the entry-point - Added an if-check to check if the item is, in fact, a directory before removing it from the list of directories. This made navigation possible to the last most child directory, otherwise it would show nothing
…first to see if the directory exists, if it didn't gave an error because the database is expected to always return a value
…empty. This happens when the directory or file doesn't exist. As part of the sequence (maybe specific to Windows mapped drives), it does a PROPFIND before running MKCOL/Get etc.
…e WebDAV response when an item doesn't exist. PROPFIND runs before MKCOL so it's important not to throw an exception in this sequence
… requesting dumb windows files (Usually through Mapped Drive on Windows machines)
…hen Windows, by default, creates "New Folder" for you to rename when creatng. This should be cross-platform compatible.
…directory info instead of the actual directory referenced
…ent instead of the directory being renamed - Updated Name to match Title
|
Forgot to update the tests |
| } | ||
| private bool HasInvalidChars(string directoryName) | ||
| { | ||
| return (!string.IsNullOrEmpty(directoryName) && directoryName.IndexOfAny(Path.GetInvalidPathChars()) >= 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove extra parentheses "(" ")"
|
|
||
| return "text/plain"; | ||
| } | ||
| private bool HasInvalidChars(string directoryName) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private static
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason why it should be static? Im trying to learn clean architecture as I go
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not about clean architecture, but about clean code. Since the method does not use class members, it should be defined as static
| var directories = relativePathTrim.Split("/").Where(x => !string.IsNullOrEmpty(x)).ToList(); | ||
|
|
||
| var isDirectory = relativePathTrim.EndsWith("/"); | ||
| var isDirectory = relativePathTrim == "/" || !Path.HasExtension(relativePathTrim); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The file name does not necessarily contain extensions (for example, "my_file_name"), you need to check for the presence of a "/" at the end.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All path names, even directories via WebDAV comss through with no "/" at the end of the name, which meant that all directories other than root were seen as files, and took the wrong code-path
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thats problem concrete client, by specification required / for collections (folder)
http://www.webdav.org/specs/rfc4918.html#rfc.section.5.2.p.8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not from what I observed. URL does end with "/" (even files), but path via GetPath doesnt. Might be the way Microsoft implemented WebDAV via the map network drive functionality, which would be strange not to follow RFC (but not unlike Microsoft). Other WebDAV server we are running follows RFC and works with that though. Maybe I am missing something.
| public async Task<string> PropfindAsync(string? path, CancellationToken cancellationToken) | ||
| public async Task<IActionResult> PropfindAsync(string? path, CancellationToken cancellationToken) | ||
| { | ||
| if (path is not null && (path.Contains("desktop.ini") || |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do these files need to be hidden?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Annoying windows explorer-only stuff that gets checked on a file system that would never contain them *shrug :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Place the list of files in a separate class, something like this
public static class WebDavConsts {
public static string[] ExcludeHiddenFiles = new[] { ... }
}
...
// use
if (WebDavConsts.ExcludeHiddenFiles.Any(path.Contains)) { ... }
| if (item == null) | ||
| { | ||
| throw new FileStorageException(ErrorCodes.PartOfPathNotExists); | ||
| return default; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use http://www.webdav.org/neon/litmus/ for testing all changes, especially this place
| .Where(x => x.IsDirectory) | ||
| .Where(x => x.Title == srcPath.ResourceName) | ||
| .Where(x => x.DirectoryId == directoryId) | ||
| .Where(x => x.Id == directoryId) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in this filter, the item is searched by the parent directory in which it should be located and the name of the items, and not by its id. If we had an id here, it would be enough to do Find(id)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From my observations, in sub-directories, that is not in root, this results in not finding any information from the database. Works fine if all directories will always be in root
Uh oh!
There was an error while loading. Please reload this page.